package net.huashitong.user.dao;

import java.util.List;

import net.huashitong.user.entity.VoiceRecord;
import net.huashitong.user.filter.VoiceRecordFilter;

import org.springframework.stereotype.Repository;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;

@Repository
public class VoiceRecordDao extends StringDao<VoiceRecord> {

	public List<VoiceRecord> queryByfilter(VoiceRecordFilter filter) {
		GenericQuery query = createQuery("obj");
		query.append(" and obj.userId = :userId").setParam("userId", filter.getUserId());
		query.append(" and obj.date = :date").setParam("date", filter.getDate());
		return query.listResult();
	}

	public List<String> queryByUserId(String userId) {
		String hql = "select distinct(obj.date) from VoiceRecord obj";
		
		GenericQuery query = create(hql);
		query.append(" where userId = :userId order by obj.date desc").setParam("userId", userId);
		
		return query.listResult();
	}

}
